<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				$('.select-chosen').chosen();
				$('.date-picker').datepicker();
				ligerTable = $('#table').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/${route}/getList1',
					delayLoad:false,
					columns:[
					    {display:'所属公司',name:'companyName',id:'companyName',align:'center',minWidth:100},
						{display:'单号',name:'tripNo',id:'tripNo',align:'center',minWidth:150},
						{
							display:'服务业务',
							name:'serviceCode',
							id:'serviceCode',
							align:'center',
							render:function(row){
								var serviceCode = row.serviceCode;
								<#list serviceCodeList as item>
								if(serviceCode == '${item.serviceCode}'){
									return '${item.serviceName}';
								}
								</#list>
							}
						},
						{
							display:'行程状态',
							name:'status',
							id:'status',
							align:'center',
							width:80,
							render:function(row){
								var status = row.status;
								if((status & 1) == 1){
									return '发布';
								}
								else if((status & 4)== 4){
									return '拒单';
								}
								else if((status & 8) == 8){
									return '接单';
								}
								else if((status & 16) == 16){
									return '上车';
								}
								else if((status & 32) == 32){
									return '已支付';
								}
								else if((status & 64) == 64){
									return '等待用户';
								}
								else if((status & 128) == 128){
									return '发车';
								}
								else if((status & 256) == 256){
									return '<span style="color:#f00">司机取消</span>';
								}
								else if((status & 512) == 512){
									return '<span style="color:#f00">用户取消</span>';
								}
								else if((status & 1024) == 1024){
									return '结束';
								}
								else if((status & 2048) == 2048){
									return '<span style="color:#f00">行程过期</span>';
								}
								return '-';
							}
						},
						{
							display:'发布用户',
							name:'userType',
							id:'userType',
							align:'center',
							render:function(row){
								var userType = row.userType;
								if(userType == 1){
									return '<span style="color:#0f0">用户</span>';
								}
								else if(userType == 2){
									return '<span style="color:#00f">司机</span>';
								}
							}
						},
						{
							display:'用户',
							name:'openId',
							id:'openId',
							align:'center',
							render:function(row){
								var userType = row.userType;
								if(userType == 1 && row.linkUser){
									return row.linkUser.phoneNo;
								}
								else if(userType == 2 && row.publishDriver){
									return row.publishDriver.phoneNo;
								}
							}
						},
						{display:'起点',name:'startLocation',id:'startLocation',align:'center',minWidth:250},
						{display:'终点',name:'endLocation',id:'endLocation',align:'center',minWidth:250},
						{
							display:'发布时间',
							name:'createTime',
							id:'createTime',
							align:'center',
							minWidth:120,
							render:function(row){
								var createTime = row.createTime;
								if(row.createTime != null){
									return formatDate(createTime * 1000);
								}
								return '-';
							}
						},
						{
							display:'发车时间',
							name:'goTime',
							id:'goTime',
							align:'center',
							minWidth:120,
							render:function(row){
								var goTime = row.goTime;
								if(row.goTime != null){
									return formatDate(goTime * 1000);
								}
								return '-';
							}
						},
						{display:'车等级',name:'carRank',id:'carRank',align:'center'},
						{display:'乘客数',name:'crewCount',id:'crewCount',align:'center'},
						{display:'距离(米)',name:'distance',id:'distance',align:'center'},
						{display:'行程定金(元)',name:'depositPayFee',id:'depositPayFee',align:'center'},
						{display:'行程剩余费用(元)',name:'payFee',id:'payFee',align:'center',minWidth:120},
                        {display:'服务机构',name:'companyservice.serviceName',id:'.companyservice.serviceName',align:'center',minWidth:200},
					]
					/**,
					onDblClickRow: function (data, rowindex, rowobj){
						layer.open({
							title:'${module}',
							type:2,
							maxmin:false,
							area: ['100%', '100%'],
							content:'${base}/${route}/view/'+data.tripNo
						});
					}
					**/
				});
				
				function reload(){
					if(ligerTable){
						var userType = $('#userType').val();
						var status = $('#status').val();
						var serviceCode = $('#serviceCode').val();
						var startTime = $('#txtStartTime').val();
						var endTime = $('#txtEndTime').val();
						var searchKey = $('#txtSearchKey').val();
						ligerTable.setParm('userType',userType);
						ligerTable.setParm('status',status);
						ligerTable.setParm('serviceCode',serviceCode);
						ligerTable.setParm('startTime',startTime);
						ligerTable.setParm('endTime',endTime);
						ligerTable.setParm('searchKey',searchKey);
						ligerTable.reload();
					}
				}
				$('#btnSearch').click(function(){
					reload();
				})
				
				$('#btnTripCrews').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.tripNo == ''){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var tripNo = row.tripNo;
			        	var url='${base}/${route}/crews/'+tripNo;
			            changePage(url);
			    	}
				});
				
				$('#btnTripStatus').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.tripNo == ''){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var tripNo = row.tripNo;
			        	var url='${base}/${route}/status/'+tripNo;
			            changePage(url);
			    	}
				});
			});
		//-->
		</script>
	</head>
	<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
		<div class="widget-box">
			<div class="widget-header widget-header-flat">
				<h5 class="lighter">
					<i class="fa fa-search"></i>
					${module}查询
					地区：${areaName}
				</h5>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="row">
						<div class="input-daterange input-group col-sm-10">
							<span class="input-group-addon">时间段</span>
							<input class="form-control date-picker" id="txtStartTime" type="text" value="${startTime}" data-date-format="yyyy-mm-dd" />
							<span class="input-group-addon">
								<i class="fa fa-calendar"></i>
							</span>
							<span class="input-group-addon">
								<i class="fa fa-exchange"></i>
							</span>
							<input class="form-control date-picker" id="txtEndTime" type="text" value="${endTime}" data-date-format="yyyy-mm-dd" />
							<span class="input-group-addon">
								<i class="fa fa-calendar"></i>
							</span>
						</div>
					</div>
					<div class="space-4"></div>
					<div class="row">
						<div class="col-sm-3 input-group">
							<span class="input-group-addon">服务业务</span>
							<select id="serviceCode">
								<option value="">全部</option>
								<#if serviceCodeList?exists && serviceCodeList?size gt 0>
								<#list serviceCodeList as item >
								<option value="${item.serviceCode}">${item.serviceName}</option>
								</#list>
								</#if>
							</select>
						</div>
						<#if user?exists && companyRole?exists && user.roleId != companyRole>
                            <div class="col-sm-3 input-group">
                                <span class="input-group-addon">所属公司</span>
                                <select id="companyId" class="width-100">
                                    <option value="">全部</option>
                                    <#if companyList?exists && companyList?size gt 0>
                                    <#list companyList as item >
                                    <option value="${item.companyId}">${item.ownerName}</option>
                                    </#list>
                                    </#if>
                                </select>
                            </div>
                        </#if>
						<div class="col-sm-3 input-group">
							<span class="input-group-addon">行程状态</span>
							<select id="status" class="width-100">
								<option value="0">全部</option>
								<option value="1">发布</option>
								<!--<option value="2">定金支付</option>//-->
								<option value="4">接单</option>
								<option value="8">拒单</option>
								<option value="16">上车</option>
								<option value="32">已支付</option>
								<option value="64">等待用户</option>
								<option value="128">发车</option>
								<option value="256">司机取消</option>
								<option value="512">用户取消</option>
								<option value="1024">结束</option>
								<option value="2048">行程过期</option>
							</select>
						</div>
					</div>
					<div class="space-4"></div>
					<div class="row">
						<div class="col-sm-10">
							<div class="input-group">
								<span class="input-group-addon">关键字</span>
								<input id="txtSearchKey" type="text" class="form-control search-query" placeholder="请输关键字搜索" />
								<span class="input-group-btn">
									<button id="btnSearch" type="button" class="btn btn-purple btn-sm">
										查询
										<i class="icon-search icon-on-right bigger-110"></i>
									</button>
								</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">
					<i class="icon-table"></i>
					${module}列表
				</h5>
				<!--非查询者有该操作-->
				<#if user?exists && viewerRole?exists && user.roleId != viewerRole>
				<div class="widget-toolbar">
					<button id="btnTripCrews" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-user-circle-o"></i>查看乘客
					</button>
					<button id="btnTripStatus" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-sort-numeric-asc"></i>行程状态
					</button>
				</div>
				</#if>
			</div>
			<div class="widget-body">
				<div id="table"><div>
			</div>
		</div>
	</body>
</html>